<?php
if (!defined('IN_XLP')) {
    exit('Access Denied');
}
$Document = array(
    'pageid' => 'user-center', //页面标示
    'pagename' => '', //当前页面名称
    'mycss' => array('index/common','index/style','index/user','index/date_style'), //加载的css样式表
    'myjs' => array('global/jquery-2.2.4.min','global/layer/layer','index/moment','index/bootstrap-datetimepicker','index/personalCenter'), //加载的js脚本
    'footerjs'=>array(),
    'head'=>true//是否加载头部文件
);
include getTpl('header', 'public');
?>
<body>
<?php include getTpl('small_top' , 'public'); ?>
<style>
  .select_group select option {
    position: absolute;
    left: 20px;
  }
</style>
<div class="container">
    <!-- 头部导航条以及搜索框 -->
    <?php include getTpl('top' , 'public'); ?>
    <?php include getTpl('aside' , 'public'); ?>
    <!-- 右侧会员中心 -->
     <section id="personal_center" class="personal_center">
      <div class="top_line">
          <span class="vip_center_text"> 个人中心 </span>
      </div>
      <div class="personal_container">
        <div class="head_set">
          <img id="head_img" onclick="setHeadImg()" style="width: 120px; height: 120px;border-radius:50%" src="<?php echo $head ?>" alt="头像">
          <label for="head_file">
            <button id="set_head_btn" onclick="setHeadImg()" class="head_set_btn">头像设置</button> 
          </label>
          
        </div>
        <form method="post" id="sForm" enctype ="multipart/form-data">
          <input type="file" id="head_file" name="headimgurl" style="display: none;">
          <div class="int">
            <label for="username">用户名</label>
            <input type="text" id="username" name="username" value="<?php echo user::$userInfo['username'] ?>" placeholder='请填写用户名'>
          </div>
          <div class="int_radio">
            <label>性别</label>
            <label class="sex_label <?php if(user::$userInfo['sex'] == 1){  ?>active_label <?php } ?>" style="margin-left: 30px;" for="sex_male">
              <svg xmlns="http://www.w3.org/2000/svg" style="margin: 0 16px 13px 0" width="19.78" height="24.5" viewBox="0 0 19.78 24.5">
                <path id="path_male" data-name="形状 7" class="cls-1 active_svg" d="M1092.05,436.825s-0.72-2.624-1.02-3.736c-0.55.917-2.19,3.667-3.04,5.091a8.285,8.285,0,0,1-2.8,14.811,8.593,8.593,0,0,1-10.46-5.927,8.333,8.333,0,0,1,6.02-10.23,8.639,8.639,0,0,1,5.18.258c0.85-1.382,2.55-4.159,3.13-5.108l-4.12,1.075-0.61-2.229,7.47-1.951,0.38-.1,2.05,7.475Zm-15.04,9.645a6.212,6.212,0,0,0,7.57,4.293,6.03,6.03,0,0,0,4.35-7.408,6.218,6.218,0,0,0-7.57-4.293A6.022,6.022,0,0,0,1077.01,446.47Z" transform="translate(-1074.44 -428.781)"/>
              </svg>
            </label>
            <label class="sex_label <?php if(user::$userInfo['sex'] == 2){  ?>active_label <?php } ?>" for="sex_female">
              <svg xmlns="http://www.w3.org/2000/svg" style="margin: 0 16px 13px 0" width="17" height="24" viewBox="0 0 17 24">
                <path id="path_female" class="cls-1" d="M1180.62,446.148v1.15h4.89v2.376h-4.89v3.315h-2.39v-3.315h-4.91V447.3h4.91v-1.173A8.495,8.495,0,1,1,1180.62,446.148Zm-1.12-14.762a6.235,6.235,0,1,0,6.16,6.235A6.209,6.209,0,0,0,1179.5,431.386Z" transform="translate(-1171 -429)"/>
              </svg>
            </label>
            <label class="sex_label <?php if(user::$userInfo['sex'] == 3){  ?>active_label <?php } ?>" for="sex_secret">
              <svg xmlns="http://www.w3.org/2000/svg" style="margin: 0 15px 15px 0" width="20" height="20" viewBox="0 0 20 20">
                <path id="path_secret" data-name="形状 8" class="cls-1" d="M1268.56,433.353a10,10,0,1,0,14.09,1.2A9.994,9.994,0,0,0,1268.56,433.353Zm0.69,12.5a7.516,7.516,0,0,1,.04-9.752l9.57,11.361A7.517,7.517,0,0,1,1269.25,445.85Zm11.46,0.052-9.57-11.361A7.526,7.526,0,0,1,1280.71,445.9Z" transform="translate(-1265 -431)"/>
              </svg>
            </label>

            <input type="radio" name="sex" value='1' id="sex_male" value="男" onclick="chooseSex()" style="display: none;">
            <input type="radio" name="sex" value='2' id="sex_female" value="女" onclick="chooseSex()" style="display: none;">
            <input type="radio" name="sex" value='3' id="sex_secret" value="保密" onclick="chooseSex()" style="display: none;">
          </div>
          <div class="int">
            <label for="personinfo">生日</label>
            <div style="margin-left: 30px;" class="iDate date">
              <input style="margin-left: 0" type="text" name="birthday" value="<?php echo user::$userInfo['birthtime'] ?>">
              <button type="button" class="addOn"></button>
            </div>
          </div>
          <div class="int">
            <button class="save_info"> 保存 </button>
          </div>
        </form>
      </div>
    </section>
    <!-- 个人中心结束 -->
    <script type="text/javascript">
        $(function(){
            $('#sForm').submit(function(){
                if(!$('#username').val()) {
                    layer.msg('请填写用户名');
                    return false;
                }
                $.ajax({
                  url: "<?php echo U('user/saveUser') ?>",
                  type: 'POST',
                  cache: false,
                  data: new FormData($(this)[0]),
                  processData: false,
                  contentType: false
              }).done(function(res) {
                var jsonObj = $.parseJSON(res);
                if(jsonObj.data){
                    $("#himage").attr('src' , jsonObj.data);
                }
                layer.msg('个人信息设置成功');

              }).fail(function(res) {});
                return false;
            });
        });
    </script>
</div>
<?php include getTpl('footer', 'public');  ?>
</body>
</html>